package com.fxd.crm.web.controller.student;

import com.fxd.crm.model.CourseOrder;
import com.fxd.crm.model.PageResult;
import com.fxd.crm.model.curdResult;
import com.fxd.crm.model.student;
import com.fxd.crm.service.ICourseOrderService;
import com.fxd.crm.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @auther fuxudong
 * @date 2021/4/3 - 14:03
 */
@RestController
@RequestMapping("/student")
public class StudentBodyController {
    @Autowired
    IStudentService studentService;

    /**
     * page:显示当前页
     * limit：每次显示多少条
     *
     * @return
     */
    @RequestMapping("listjson")
    public PageResult<student> listJson(student student, int page, int limit) {
        PageResult<student> pageResult = studentService.findPageResult(student, page, limit);
        return pageResult;
    }

    @RequestMapping("save")
    public curdResult save(student student) {
        curdResult curdResult;
        System.out.println(student);
        if (student.getUuid() != null) {
            curdResult = new curdResult(1, "成功");
            studentService.update(student);
        } else {
            curdResult = new curdResult(1, "成功");
            studentService.save(student);
        }
        return curdResult;
    }

    @RequestMapping("delete")
    public curdResult delete(Integer uuid) {
        curdResult curdResult = new curdResult();
        studentService.deleteByUuid(uuid);
        return curdResult;

    }


}
